home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / umich / diskutil / arcbit.lzh / ARCBIT.BAS next >
Encoding:
BASIC Source File  |  1990-01-19  |  3.4 KB  |  122 lines

  1. ' **** ARCBIT multiple archive bit adjuster  (LDW BASIC 2.0 source code)
  2. '
  3. DEF PROC FILECOUNT(PATH$)
  4.      D#=PEEK_L(VARPTR(PATH$))
  5.      GEMDOS 78,D#,0
  6.      check_gemdos#=STATUS
  7.      NFILES@=0
  8.      WHILE check_gemdos#>=0
  9.           GEMDOS 79
  10.           check_gemdos#=STATUS
  11.           NFILES@=NFILES@+1
  12.      WEND
  13. ENDPROC NFILES@
  14.  
  15. OPENW 0,0,0,640,200,1
  16. TITLEW 0," ARCHIVE BIT ADJUSTER "
  17. gotoxy 39,0:print "by"
  18. gotoxy 34,2:print "Allan Zachary"
  19. RESET
  20. path$="\*.*"
  21. start:
  22. selected_file$=""
  23. f$=""
  24. if nfiles@ then erase file_list$
  25. alert 0," Choose a path... ",1," OK | DONE ",answer@
  26. if answer@=2 then end
  27. ask file path$,selected_file$,f$,found@
  28. if found@<>1 then end
  29. i@=len(path$)
  30. while mid$(path$,i@,1)<>"\" and i@>0
  31.      i@=i@-1
  32. wend
  33.  
  34. if i@>0 then
  35.      folder$=left$(path$,i@)
  36.    else
  37.      alert 3," Pathname error? ",1," REDO | QUIT ",answer@
  38.      if answer@=2 then end
  39.      goto start
  40. endif
  41.  
  42. nfiles@=proc filecount(path$)
  43. if nfiles@=0 then
  44.      alert 3," No files found! ",1," OK ",answer@
  45.      gosub top_bar
  46.      goto start
  47. endif
  48. dim file_list$(nfiles@)
  49. message$= str$(nfiles@)+" files,- getting filenames... "
  50. titlew 0,message$
  51.  
  52. 'set up directory search
  53. d#=peek_l(varptr(path$))
  54. gemdos 78,d#,0
  55.  
  56. for i@=1 to nfiles@
  57.  
  58.      gemdos 47 'find disk transfer address
  59.      dta_adr#=status
  60.  
  61.      filename$=""
  62.      a=1
  63.      for j@=0 to 13
  64.        if a=0 then goto finished
  65.           a=peek_b(dta_adr#+30+j@)
  66.           filename$=filename$+chr$(a)
  67.        finished:
  68.      next j@
  69.      file_list$(i@)=folder$+filename$
  70.      gemdos 79
  71. next i@
  72.  
  73. gosub top_bar
  74. alert 2," Set archive bit ",2," ON | OFF | QUIT ",mode@
  75.  
  76. if mode@=1 then
  77.      message$=" Turning archive bits on... " 
  78.      titlew 0,message$
  79.      for i@=1 to nfiles@
  80.           gotoxy 1,1:print using "### of ###",i@,nfiles@
  81.           d#=peek_l(varptr(file_list$(i@)))
  82.           gemdos 67,d#,1,32  'put file archived attribute
  83.           check_gemdos#=status
  84.           if check_gemdos#<0 then gosub gd_error
  85.      next i@
  86.   elseif mode@=2 then
  87.      message$=" Turning archive bits off... " 
  88.      titlew 0,message$
  89.      for i@=1 to nfiles@
  90.           gotoxy 1,1:print using "### of ###",i@,nfiles@
  91.           d#=peek_l(varptr(file_list$(i@)))
  92.           gemdos 67,d#,1,0  'put file NOT archived attribute
  93.           check_gemdos#=status
  94.           if check_gemdos#<0 then gosub gd_error
  95.      next i@
  96.   elseif mode@=3 then
  97.      end
  98. endif
  99. gosub top_bar
  100. goto start
  101.  
  102. gd_error:
  103.           gd_error$=""
  104.           if check_gemdos#=-32 then gd_error$="| (Invalid function number) "
  105.           if check_gemdos#=-33 then gd_error$="| (file not found) "
  106.           if check_gemdos#=-34 then gd_error$="| (path not found) "
  107.           if check_gemdos#=-35 then gd_error$="| (too many files open) "
  108.           if check_gemdos#=-36 then gd_error$="| (access denied) "
  109.           if check_gemdos#=-39 or check_gemdos#=-41 or check_gemdos#=-42 then gd_error$="| (insufficient memory) "
  110.           if check_gemdos#=-46 then gd_error$="| (Invalid drive specified) "
  111.           if check_gemdos#=-47 then gd_error$="| (Invalid operation) "
  112.           if check_gemdos#=-49 then gd_error$="| (no more files) "
  113.           message$=" GEMDOS error #"+str$(check_gemdos#)+"! "+gd_error$
  114.           alert 0,message$,1," ok | quit ",answer@
  115.           if answer@=2 then end
  116. return
  117.  
  118. top_bar:
  119.      OPENW 0
  120.      TITLEW 0," ARCHIVE BIT ADJUSTER "
  121. return
  122.